﻿#ifndef PST_LINECHARTCENTERSETTINGDIALOG_H
#define PST_LINECHARTCENTERSETTINGDIALOG_H

#include <IdaDialogFrame>
#include <tuple>
#include <QList>
#include "InfomationCurve2DBasical.h"
QT_BEGIN_NAMESPACE
namespace Ui
{
    class LineChartCenterSettingDialog;
};
QT_END_NAMESPACE

class QComboBox;
class QTableWidget;

namespace pst
{
    class LineChartCenterSettingData;

    class LineChartCenterSettingDialog : public IdaDialogFrame
    {
        Q_OBJECT

    public:
        LineChartCenterSettingDialog(QWidget* parent = nullptr);
        ~LineChartCenterSettingDialog();

        void initWidget();

        void InitData(LineChartCenterSettingData* dataGraph2DSettings);

        void ChangeCurrentWidget(int index);

        void setWindowUniversalID(int windowUniversalID);
        void setIndexOfGraph(int index);
        int getIndexOfGrapg() const;

        void setCurveInfoID(int curveInfoID) { m_curveInfoID = curveInfoID; };
        int getCurveInfoID() const { return m_curveInfoID; };

    signals:
        void SignalSendData(int windowUniversalID,int curveInfoID, Info2DPointer info = nullptr);
        void signal_checkCurveNameExist(QString curveName, bool& exist);

    private slots:

        void reject() override;

        void accept() override;

        bool slot_apply();

        void slot_xAxisUnitChanged(int index); //x轴单位更改
        void slot_yAxisUnittypeChanged(int index);//y轴单位类型更改
        void slot_yAxisUnitComponentChanged(int index);//y轴单位分量更改
        void slot_yAxisUnitChanged(int index); //y轴单位更改

    private:
        //axisType = 0:xAxis, axisType = 1:yAxis
        QTableWidget* initData_xAxisDisplay(int axisType);
        QTableWidget* initData_xAxisRange();
        QTableWidget* initData_yAxisDisplay();
        QTableWidget* initData_yAxisRange();
        QTableWidget* initData_grid();
        QTableWidget* initData_title();
        QTableWidget* initData_legend();
        QTableWidget* initData_dataProperty();

        void saveUIData_xAxisDisplay();
        bool saveUIData_xAxisRange();
        void saveUIData_yAxisDisplay();
        bool saveUIData_yAxisRange();
        void saveUIData_grid();
        void saveUIData_title();
        void saveUIData_legend();
        void saveUIData_dataProperty();

        void updateUIData_xAxisDisplay();
        void updateUIData_xAxisRange();
        void updateUIData_yAxisDisplay();
        void updateUIData_yAxisRange();
        void updateUIData_grid();
        void updateUIData_title();
        void updateUIData_legend();
        void updateUIData_dataProperty();

        //从m_yAxisUnitList里面，根据文件类型获取添加的分量，比如增益文件的 实部、相位等
        QList<int> getAddedComponentTypeListByFileType(int fileType);
        QString getCurrentUnitByType(int fileType, int componentType);

    signals:
        //void pyScriptIsRunning();

    private:
        Ui::LineChartCenterSettingDialog* ui;
        LineChartCenterSettingData* m_dataGraph2DSettings;
        QTableWidget* m_tableWidget_xAxisDisplay;
        QTableWidget* m_tableWidget_xAxisRange;
        QTableWidget* m_tableWidget_yAxisDisplay;
        QTableWidget* m_tableWidget_yAxisRange;
        QTableWidget* m_tableWidget_grid;
        QTableWidget* m_tableWidget_title;
        QTableWidget* m_tableWidget_legend;
        QTableWidget* m_tableWidget_dataProperty;

        int m_windowUniversalID;
        int m_curveInfoID{-1};
        int m_indexOfGraph{ -1 };
        QStringList m_pyCode; // python脚本

        //QComboBox* m_comboBox_xAxisUnit{ nullptr };
        QComboBox* m_comboBox_yAxisUnitType{ nullptr };
        QComboBox* m_comboBox_yAxisComponentType{ nullptr };
        QComboBox* m_comboBox_yAxisUnit{ nullptr };

        QList<std::tuple<int, int, QString>> m_yAxisUnitList;//存储多个结果类型的当前单位

    };
} // namespace pst
#endif // PST_DIALOGGRAPH2DSETTINGS_H
